<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Worksheet_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}

	public function save_task($insert)
	{
	 	$this->db->insert('worksheet',$insert);
	}
	public function get_worksheet($year_id,$month_id)
	{
		$where = array(
		'year_id'=> $year_id,
		'month_id' => $month_id,
		'user_id' => $this->session->userdata('user_id'),		
		);
		//print_r($where);exit;
		return $this->db->group_by('date_id')->get_where('worksheet',$where)->result();
		//$this->db->group_by("date"); 
		//$this->db->distinct('date');
		//$this->db->where('user_id',$user_id);
	//	$this->db->where($where);
	//return	$this->db->get('worksheet')->result();
		
		// $this->db->result();
	}
	
	public function get_worksheet_months()
	{
		$this->db->distinct('month_id');
		$this->db->select('month_id,year_id');
		$this->db->where('user_id', $this->session->userdata('user_id'));
		return $query = $this->db->get('worksheet')->result();
	}
	
	public function get_worksheet_date_time($date){
		$this->db->select('*')->from('worksheet')->where('date_id', $date);
		return $query = $this->db->get()->result();
	}
	
	public function delete_worksheet($id)
	{
		$this->db->delete('worksheet',array('id'=>$id));
	}

}
?>
